precision mediump float;
varying vec2 v_texCoord;
uniform sampler2D s_texture;

uniform float u_width;
uniform float u_height;


void main()                                            
{
	vec2 UL, UR, DL, DR;
	
   float dx = pow(u_width, -1.0) * 0.25;
   float dy = pow(u_height, -1.0) * 0.25;
   vec3 dt = vec3(1.0, 1.0, 1.0);

    
   UL =   v_texCoord + vec2(-dx, -dy);
   UR =    v_texCoord + vec2(dx, -dy);
   DL =    v_texCoord + vec2(-dx, dy);
   DR =    v_texCoord + vec2(dx, dy);
   

   vec3 c00 = texture2D(s_texture, UL).xyz;
   vec3 c20 = texture2D(s_texture, UR).xyz;
   vec3 c02 = texture2D(s_texture, DL).xyz;
   vec3 c22 = texture2D(s_texture, DR).xyz;

   float m1=dot(abs(c00-c22),dt)+0.001;
   float m2=dot(abs(c02-c20),dt)+0.001;
  
   gl_FragColor = vec4((m1*(c02+c20)+m2*(c22+c00))/(2.0*(m1+m2)),1.0);
}
 
 
 
 
 
 
 
 
 